#
#===============================================================================
#
#         FILE:  Rank.pm
#
#  DESCRIPTION:  
#
#        FILES:  ---
#         BUGS:  ---
#        NOTES:  ---
#       AUTHOR:   (), <>
#      COMPANY:  
#      VERSION:  1.0
#      CREATED:  04/14/2010 11:41:14 PM GMT
#     REVISION:  ---
#===============================================================================

use strict;
use warnings;

package GoogPl::Rank;

use WWW::Google::PageRank;

sub register {
    my $self = shift;

    return ('cmd' => 'rank', 'pat' => '^!rank\s+(http:.*)');
}

sub help {
    my $self = shift;

    return (
	    'Get the current Google page rank of a site'
	   );
}

sub process_command {
    my $self = shift;
    my ($kernel, $sender, $nickhost, $target, $msgtxt, %conf) = @_;

    $msgtxt =~ /^!rank\s+(http:.*)/;

    my $gpr = WWW::Google::PageRank->new;
    my $pr = $gpr->get($1);

    return if ! defined $pr;

    $kernel->post($sender=>privmsg => $target =>
	    sprintf('Pagerank: %s', $pr));
}

1;
